home *** CD-ROM | disk | FTP | other *** search
/ Wayzata's Best of Shareware PC/Windows 1 / Wayzata's Best of Shareware for PC-Windows - Release 1 - Wayzata Technology (1993).iso / mac / DOS / GRAPHICS / LISS151 / FIELD.H < prev    next >
C/C++ Source or Header  |  1992-03-10  |  4KB  |  118 lines

  1. /* *****************
  2.    FIELD.H
  3.  
  4.        field input defines and functions
  5.  
  6.        Program originally written by Dan Farmer using algorithms from
  7.        Clifford Pickover.  Converted from QuickBasic to C by Aaron C. Caba.
  8.        See Scientific American January 1991 and Omni February 1990 for
  9.        excellent examples by Pickover.
  10.  
  11.  
  12. History:
  13.  
  14.  Version 1.5:
  15.   03/10/92 ACC Move #includes from field.c to field.h
  16.  
  17.  Version 1.4:
  18.   02/11/92 ACC Major rearangement of all code:
  19.                  move all field manipulation prototypes to FIELD.H
  20.                  clean up header files so only necessary stuff is in each
  21.   02/06/92 ACC split field input functions off from LISSAJOU.C
  22. */
  23.  
  24. /*=========================== Defined constants ========================*/
  25.  
  26. #ifndef _FIELD
  27. #define _FIELD
  28.  
  29. #define CHAR_BOX_X              8   /* size of the graphics-            */
  30. #define CHAR_BOX_Y             10   /* character boxes                  */
  31. #define MESSAGE_Y_POS          32   /* text Y pos of displayed messages */
  32.  
  33. #define FALSE                   0   /* Handy return values              */
  34. #define TRUE               !FALSE
  35. #define NO_EXIT                 0
  36. #define EXIT                   -1
  37.  
  38. #define MAXFIELDS              15   /* Number of input fields           */
  39. #define MAX_FIELD_LEN          47   /* maximum length of a data field   */
  40.  
  41. #define UP            0x48          /* scan codes of control characters */
  42. #define DOWN          0x50
  43. #define PGUP          0x49
  44. #define PGDN          0x51
  45. #define F10           0x44
  46. #define ESC           0x1B
  47. #define RETURN        '\r'
  48. #define BKSPC         '\b'
  49.  
  50. #include <alloc.h>
  51. #include <conio.h>
  52. #include <ctype.h>
  53. #include <graphics.h>
  54. #include <math.h>
  55. #include <stdio.h>
  56. #include <stdlib.h>
  57. #include <string.h>
  58. #include "error_fn.h"   /* error handling routine       */
  59. #include "defines.h"    /* global defines ie MAXFIELDS  */
  60.  
  61. /*=============================== enum's ===============================*/
  62. /* the different input fields */
  63. enum {MAIN_RADIUS, A, B,
  64.       EXPONENT_X, EXPONENT_Y, EXPONENT_Z,
  65.       SPH_RADIUS, SPHERES, AXIS, ALGO, ROTATE,
  66.       FILE_NAME, NUMCOLORS, COLOR_NAME, ALGO_EQN};
  67.  
  68.  
  69. enum {INTEGER, DECIMAL, XYZ, SIGNED_INTEGER, ALPHA};
  70.  
  71. /*============================ Field Structure  ========================*/
  72.  
  73. /* structure field_type.  Holds:  label -- name of the field
  74.                                   len -- length of data field
  75.                                   x -- character x position of field label
  76.                                   y -- character y position of field label
  77.                                   type -- type of data the field holds
  78. */
  79. struct field_struct {
  80.     char label[18]; 
  81.     int len; 
  82.     int x; int y; 
  83.     int type;
  84. };
  85.  
  86. /*========================== Function Prototypes =======================*/
  87.  
  88. void assign_default(char *data[]);
  89.  
  90. /* Process a control character from the keyboard.  If backspace,
  91.    delete last character in 'data'
  92.    Return control character pressed */
  93. char control_char(char ch, char *data, int *chcount);
  94.  
  95. /* Print all data fields */
  96. void disp_data(char *data[]);
  97.  
  98. /* Print data from field 'n' in color 'color' */
  99. void disp_field(int n, char *data, int color, int dy);
  100.  
  101. /* Print 'str' in bottom window */
  102. void disp_message(char *str);
  103.  
  104. /* Print text at text coords (x,y) in color 'color' */
  105. void disp_text(int x, int y, char *msg, int color);
  106.  
  107. /* Erase text for 'n' spaces at text position (x,y) */
  108. void erase_text(int x, int y, int n);
  109.  
  110. /* Edit field # 'fieldnum', and put new string in 'data'
  111.    Return which control key was pressed */
  112. int  fieldinput(int fieldnum, char *data, char *msg, int dy);
  113.  
  114. /* Print "msg"+"(Y or N)" on bottom panel
  115.    Return TRUE for Y or FALSE for N */
  116. int  verify(char *msg);
  117.  
  118. #endif